# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: Mateusz Herych <heniekk@gmail.com>
# Contributor: Charles Lindsay <charles@chaoslizard.org>

pkgbase=vhba-module
pkgname=(vhba-module vhba-module-dkms)
pkgver=20211218
pkgrel=119
pkgdesc="Kernel module that emulates SCSI devices"
url="https://cdemu.sourceforge.io/"
arch=(loong64 x86_64)
license=(GPL)
makedepends=('linux-headers')
source=("https://downloads.sourceforge.net/cdemu/$pkgbase-$pkgver.tar.xz"
        dkms.conf)
sha256sums=('72c5a8c1c452805e4cef8cafefcecc2d25ce197ae4c67383082802e5adcd77b6'
            '8cab0ebb4fee72069d63616b0983f105b98d1261e72e9bef5509a6e60bc382a7')

prepare() {
  cd $pkgbase-$pkgver
}

build() {
  cd $pkgbase-$pkgver
  make KERNELRELEASE="$(</usr/src/linux/version)"
}

package_vhba-module() {
  depends=(linux)
  provides=(VHBA-MODULE)

  local extradir="/usr/lib/modules/$(</usr/src/linux/version)/extramodules"
  install -Dt "$pkgdir$extradir" -m644 $pkgbase-$pkgver/*.ko

  find "$pkgdir" -name '*.ko' -exec strip --strip-debug {} +
  find "$pkgdir" -name '*.ko' -exec xz {} +
}

package_vhba-module-dkms() {
  depends=(dkms)
  provides=(VHBA-MODULE)
  conflicts=(vhba-module)

  install -Dt "$pkgdir/usr/src/$pkgbase-$pkgver" -m644 \
    dkms.conf $pkgbase-$pkgver/{Makefile,vhba.c}
}

# vim:set ts=2 sw=2 et:
